
while true {
    moveForward()
    
    if isOnGem {
        collectGem()
        
    }
    
    if isOnClosedSwitch {
        toggleSwitch()
        
    }
    
    if isBlocked && isBlockedLeft && isBlockedRight {
        break
    }
 
    if isBlocked && isBlockedRight {
        turnLeft()
        
    }
    
    if isBlocked && isBlockedLeft {
        turnRight()
        
    }
    
    if isBlocked {
        turnLeft()
        
    }
    
}
